{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 多项式回归 Pipeline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = np.random.uniform(-3,3,size=100)\n",
    "X = x.reshape(-1,1)\n",
    "y = 0.5 * x**2 + x + 2 + np.random.normal(0,1,100) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.preprocessing import PolynomialFeatures"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(100, 3)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "poly = PolynomialFeatures(degree=2)\n",
    "poly.fit(X)\n",
    "X2 = poly.transform(X)\n",
    "X2.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 1.00000000e+00,  2.70097577e+00,  7.29527008e+00],\n",
       "       [ 1.00000000e+00, -1.52368222e+00,  2.32160751e+00],\n",
       "       [ 1.00000000e+00, -4.48392883e-02,  2.01056178e-03],\n",
       "       [ 1.00000000e+00,  2.83264996e+00,  8.02390578e+00],\n",
       "       [ 1.00000000e+00, -1.05065060e-01,  1.10386668e-02]])"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X2[:5,:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.linear_model import LinearRegression\n",
    "lin_reg2 = LinearRegression()\n",
    "lin_reg2.fit(X2,y)\n",
    "y_predict2 = lin_reg2.predict(X2)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3Xl8VNX5x/HPQwgScAkqKgQQtBhFUGlRVFRqUVFxQautqBV/omi1dWkbxbq1KgWNtbba1mJdUHGpChFBARX3KgoGBWSRtmzBCkUQlAAhOb8/bhKyzExmubPd+b5fr7ySTO7MnDszeebMc55zjjnnEBGR7Ncq3Q0QERF/KKCLiASEArqISEAooIuIBIQCuohIQCigi4gEhAK6iEhAKKCLiASEArqISEC0TuWd7bnnnq579+6pvEsRkaw3Z86c/znnOrZ0XEoDevfu3Zk9e3Yq71JEJOuZ2fJojlPKRUQkIBTQRUQCQgFdRCQgFNBFRAJCAV1EJCBSWuUiIpJLysorKJ2+mNUbKulcWEDJ4GKG9i1K2v0poIuIJEFZeQU3TpxHZVU1ABUbKrlx4jyApAV1pVxERJKgdPri+mBep7KqmtLpi5N2nwroIiJJsHpDZUyX+0EpFxERHzTNlxe2y2f95qpmx3UuLEhaGxTQRUQSFCpfnt/KyM8zqqpd/XEF+XmUDC5OWjuUchERSVCofHlVjaN9m9YUFRZgQFFhAWPO7pPeKhczewQ4DVjjnOtde9nuwLNAd2AZ8CPn3PqktVJEJIOFy4t/XVnF3NtOSlk7oumhPwac3OSyUcDrzrmewOu1v4uI5KRwefFk5stDaTGgO+feBr5qcvGZwPjan8cDQ31ul4hI1igZXExBfl6jy5KdLw8l3kHRvZ1zXwA4574ws73CHWhmI4GRAN26dYvz7kREMlddXjyVs0JDMedcyweZdQemNMihb3DOFTb4+3rnXIeWbqdfv35OG1yIiMTGzOY45/q1dFy8VS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kXM9vVObex9uergV7OuSvS3Ky4mNlJwEzn3HYzuwvAOXdDmpsVNzM7CKgB/gb8yjk3O81NipmZ5QFLgBOBVcBHwDDn3GdpbViczOw44Bvgcedc73S3JxFm1gno5Jz72Mx2AeYAQ7P4uTGgvXPuGzPLB94FrnHOfeD3fWVsD70umNdqD2TmO08UnHMznHPba3/9AOiSzvYkyjm30DmX7Zt4HgEsdc792zm3DXgGODPNbYqbc+5t4Kt0t8MPzrkvnHMf1/68CVgIZO16yc7zTe2v+bVfSYlnGRvQAcxstJmtBC4Abk13e3xyCfBKuhshFAErG/y+iiwOGkFlZt2BvsCs9LYkMWaWZ2ZzgTXAq865pJxPWgO6mb1mZvNDfJ0J4Jy7yTnXFZgA/CydbW1JS+dSe8xNwHa888lo0ZxPlrMQl2Xtp8AgMrOdgReAa5t8Ys86zrlq59xheJ/OjzCzpKTF0rpjkXPuhCgPfQqYCtyWxOYkpKVzMbPhwGnAIJepAxcNxPDcZKtVQNcGv3cBVqepLdJEba75BWCCc25iutvjF+fcBjN7EzgZ8H0AO2NTLmbWs8GvZwCL0tWWRJnZycANwBnOuc3pbo8A3iBoTzPrYWZtgPOAyWluk1A/iPgwsNA5d2+625MoM+tYV9lmZgXACSQpnmVylcsLQDFeNcVy4ArnXEV6WxUfM1sK7ASsq73og2yt2AEws7OA+4GOwAZgrnNucHpbFTszOxW4D8gDHnHOjU5zk+JmZk8D38db0e9L4Dbn3MNpbVSczOwY4B1gHt7/P8CvnXMvp69V8TOzQ4DxeK+zVsA/nHO3J+W+MjWgi4hIbDI25SIiIrFRQBcRCQgFdBGRgFBAFxEJCAV0EZGAUEAXEQkIBXQRkYBQQBcRCYj/B8ZPtAwMqRZoAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1a1456d470>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(x,y)\n",
    "plt.plot(np.sort(x),y_predict2[np.argsort(x)],color='r')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0.        , 0.99870004, 0.45769223])"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lin_reg2.coef_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(100, 1)"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Pipeline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = np.random.uniform(-3,3,size=100)\n",
    "X = x.reshape(-1,1)\n",
    "y = 0.5 * x**2 + x + 2 + np.random.normal(0,1,100) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.pipeline import Pipeline\n",
    "from sklearn.preprocessing import StandardScaler\n",
    "# 会按照管道一步步的走\n",
    "poly_reg = Pipeline([\n",
    "    (\"poly\", PolynomialFeatures(degree=2)),\n",
    "    (\"std_scaler\", StandardScaler()),\n",
    "    (\"lin_reg\",LinearRegression())\n",
    "])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Pipeline(memory=None,\n",
       "     steps=[('poly', PolynomialFeatures(degree=2, include_bias=True, interaction_only=False)), ('std_scaler', StandardScaler(copy=True, with_mean=True, with_std=True)), ('lin_reg', LinearRegression(copy_X=True, fit_intercept=True, n_jobs=1, normalize=False))])"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "poly_reg.fit(X,y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "y_predict3 = poly_reg.predict(X)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3Xl8VNX9//HXIQQMaxCDQARBQVRwwV/cW2tVwK0ad0AsaL9qq23VX8tXxAVcwVpxqdZKkboBooARFIVWxCpt0SAgi4AoIkSsQYiCBAnJ+f5xE0zCTGa7M3fJ+/l45AEZ5mbOHSafe+7nnPM5xlqLiIgEXxOvGyAiIu5QQBcRCQkFdBGRkFBAFxEJCQV0EZGQUEAXEQkJBXQRkZBQQBcRCQkFdBGRkGiayRfbb7/9bLdu3TL5kiIigbdo0aLN1tq8WM/LaEDv1q0bxcXFmXxJEZHAM8asj+d5SrmIiISEArqISEgooIuIhIQCuohISCigi4iEREZnuYiINBZFi0t4YM5qvigrp3NuDsMH9KKwb35aX1MBXUTEZUWLS7hlxjLKKyoBKCkr55YZywDSGtSVchERcdkDc1bvCeY1yisqeWDO6rS+rgK6iIjLvigrT+hxtyigi4i4rHNuTkKPu0UBXUTEZcMH9CInO6vOYznZWQwf0Cutr6tBURERl9UMfGqWi4hICBT2zU97AK9PKRcRkZBQQBcRCYmYAd0YM9EY85UxZnmtx/Y1xvzdGPNx9Z/t0ttMERGJJZ4e+tPAmfUeGwG8aa3tCbxZ/b2IiHgoZkC31v4T2FLv4fOBZ6r//gxQ6HK7REQkQcnm0Pe31m4CqP6zQ7QnGmOuMcYUG2OKS0tLk3w5ERGJJe3TFq2144HxAAUFBTbdrycikgovqiS6JdmA/l9jTCdr7SZjTCfgKzcbJSLiBa+qJLol2Z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fF/BR1O7d2iMfAAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1a1e1c90f0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(x,y)\n",
    "plt.plot(np.sort(x),y_predict3[np.argsort(x)],color='r')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
